package com.zq.designpaterns.create.factory;

import com.zq.designpaterns.create.bean.Circle;
import com.zq.designpaterns.create.bean.Rectangle;
import com.zq.designpaterns.create.bean.Square;
import com.zq.designpaterns.create.enums.ShapeType;
import com.zq.designpaterns.create.interfaces.Shape;

import java.util.Objects;

/**
 * ================================================
 * 作    者：程志强
 * 邮    箱：cheng.zhiqiang@cesgroup.com.cn
 * 版    本：1.0.0
 * 创建日期：2021/01/11  10:30
 * 修改日期：
 * 描    述：
 * 修订历史：
 * ================================================
 */
public class ShapeFactory {
    public Shape getShape(ShapeType type) {
        if (Objects.isNull(type)) {
            return null;
        }
        switch (type) {
            case CIRCLE:
                // 圆
                return new Circle();
            case SQUARE:
                // 正方形
                return new Square();
            case RECTANGLE:
                // 长方形
                return new Rectangle();
            default:
                System.out.println("ShapeType不存在===》" + type);
                return null;
        }
    }
}
